package com.practices2.base;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.Toast;

import com.practices2.R;

public class BaseActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// DEFAULT_FEATURES：系统默认状态，一般不需要指定
		// FEATURE_CONTEXT_MENU：启用ContextMenu，默认该项已启用，一般无需指定
		// FEATURE_CUSTOM_TITLE：自定义标题。当需要自定义标题时必须指定。如：标题是一个按钮时
		// FEATURE_INDETERMINATE_PROGRESS：不确定的进度
		// FEATURE_LEFT_ICON：标题栏左侧的图标
		// FEATURE_RIGHT_ICON:标题栏右侧的图标
		// FEATURE_NO_TITLE：无标题
		// FEATURE_OPTIONS_PANEL：启用“选项面板”功能，默认已启用。
		// FEATURE_PROGRESS：进度指示器功能
		this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setTheme(android.R.style.Theme_Light_NoTitleBar);

		onAfterOnCreate(savedInstanceState);
	}

	protected void onAfterOnCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub

	}

	protected String obtainCurrentClassName() {
		return this.getClass().getSimpleName();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	@Override
	protected void onRestart() {
		super.onRestart();
	}

	@Override
	public void setContentView(int layoutResID) {
		super.setContentView(layoutResID);
		onAfterSetContentView();
	}

	@Override
	public void setContentView(View view, LayoutParams params) {
		super.setContentView(view, params);
		onAfterSetContentView();
	}

	@Override
	public void setContentView(View view) {
		super.setContentView(view);
		onAfterSetContentView();
	}

	protected void onAfterSetContentView() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
	}

	@Override
	protected void onStart() {
		super.onStart();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	// @Override
	// public boolean onCreateOptionsMenu(Menu menu) {
	// getMenuInflater().inflate(R.menu.main, menu);
	// return true;
	// }

	// @Override
	// public boolean onOptionsItemSelected(MenuItem item) {
	//
	// switch (item.getItemId()) {
	// case R.id.action_settings:
	// showToast("first");
	// break;
	// case R.id.action_capture:
	// Intent intent=new Intent();
	// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	// intent.setClass(getApplicationContext(),
	// com.statistices.activity.third.TestCustomViewActivity.class);
	// startActivity(intent);
	// // Bitmap b=Util.takeShotScreen(new MainActivity());
	// // Util.saveBitmapFile(b,
	// Environment.getDataDirectory().getPath()+File.separator+"capture.png");
	// break;
	//
	// default:
	// break;
	// }
	// return super.onOptionsItemSelected(item);
	// }

	public void finish() {
		super.finish();
		overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
	}

	public void defaultFinish() {
		super.finish();
	}

	public void showToast(String str) {
		Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show();
	}

}
